<template>
	<view class="fui-wrap">
		<fui-nav-bar :title="title" background="#43afe8" color="#fff"></fui-nav-bar>
		<view class="top" style="background:linear-gradient(to bottom, #43afe8, #fff);">
			<fui-avatar width="150" height="150" radius="30" :src="userinfo.avatar"></fui-avatar>
			<fui-text :text="merchant.merch_name" type="black" size="28"></fui-text>
			<merch-balance :show-title="true" :balance="parseNumber(merchant.balance)" :settle_type="merchant.settle_type"></merch-balance>
		</view>
		<fui-grid :columns="(platform=='PC')?8:3">
			<fui-grid-item @click="$navigateTo('merchant/coupon?type=dynamic')">
				<view class="fui-grid__cell">
					<image :src="`${baseUrl}assets/img/miniapp/qrcode.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="发券-动态码" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="$navigateTo('merchant/coupon?type=static')">
					<image :src="`${baseUrl}assets/img/miniapp/redqrcode.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="发券-固定码" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="$navigateTo('merchant/couponlist')">
					<image :src="`${baseUrl}assets/img/miniapp/mcoupon.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="我发的券" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="$navigateTo('merchant/bill')">
					<image :src="`${baseUrl}assets/img/miniapp/bill.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="流水账单" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item v-if="merchant.online_recharge">
				<view class="fui-grid__cell" @click="$navigateTo('merchant/recharge')">
					<image :src="`${baseUrl}assets/img/miniapp/mrecharge.png`" class="fui-icon" mode="widthFix" style="width: 90rpx;height: 90rpx;"></image>
					<fui-text text="充值/缴费" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item v-if="merchant.online_recharge">
				<view class="fui-grid__cell" @click="$navigateTo('merchant/day')">
					<image :src="`${baseUrl}assets/img/miniapp/edit.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="预约车入场" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="$navigateTo('merchant/searchplate')">
					<image :src="`${baseUrl}assets/img/miniapp/search-plate.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="在场车辆查询" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="$navigateTo('merchant/list')">
					<image :src="`${baseUrl}assets/img/miniapp/mmerch.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="切换商户" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
			<fui-grid-item>
				<view class="fui-grid__cell" @click="logout">
					<image :src="`${baseUrl}assets/img/miniapp/mlogout.png`" class="fui-icon" mode="widthFix"></image>
					<fui-text text="退出账号" type="black" size="24"></fui-text>
				</view>
			</fui-grid-item>
		</fui-grid>
	</view>
</template>

<script>
	import {methods,baseUrl} from '@/utils/core.js';
	import {formatDuration,parseNumber} from '@/utils/util.js';
	import merchBalance from '@/components/common/merch-balance.vue';
	export default {
		components:{
			merchBalance:merchBalance
		},
		data() {
			return {
				title:'',
				baseUrl:baseUrl,
				userinfo:{},
				merchant:{},
				merchants:[],
				platform:''
			}
		},
		onLoad() {
			this.$platform();
			this.getMerchInfo();
		},
		methods: {
			...methods,
			formatDuration,
			parseNumber,
			getMerchInfo:function(){
				this.$get('merchant/index/info').then(res=>{
					this.merchant=res.merchant;
					uni.setStorageSync('merchant',res.merchant);
					this.userinfo=res.user;
					this.title=res.parking.title;
				});
			},
			logout:function(){
				this.$get('merchant/common/logout').then(res=>{
					this.$reLaunch('merchant/login');
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fui-wrap{
		background-color: #fff;
	}
	.parking{
		padding: 30rpx 0;
		text-align: center;
	}
	.top{
		background-color: #43afe8;
		display: flex;
		align-items: center;
		justify-content: space-around;
		flex-direction: column;
		height: 300rpx;
		padding: 50rpx 0 30rpx 0;
	}
	.fui-grid__cell{
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		text{
			margin-top: 10rpx;
		}
		.fui-icon{
			width: 80rpx;
			height: 80rpx;
		}
	}
</style>